package com.video_study.service.serviceImpl;

import com.video_study.dao.CourseMapper;
import com.video_study.dto.CourseDto;
import com.video_study.dto.CourseDto2;
import com.video_study.pojo.Course;
import com.video_study.result.ExceptionMsg;
import com.video_study.result.ResponseData;
import com.video_study.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class CourseServiceImpl implements CourseService {
    @Autowired
    CourseMapper courseMapper;
    public ResponseData getCourseById(String id) {
        CourseDto course = courseMapper.selectById(id);
        System.out.println(course.getCreate_time());
        return new ResponseData(course);
    }

    @Override
    public ResponseData getCourses(String type) {
        List<CourseDto2> courses = courseMapper.getCourses(type);
        return new ResponseData(courses);
    }

    @Override
    public ResponseData getTypes() {
        List<String> types = courseMapper.getTypes();
        return new ResponseData(types);
    }

    @Override
    public ResponseData updateLikes(Course course) {
        Integer result = courseMapper.updateLikes(course);
        return new ResponseData(ExceptionMsg.SUCCESS);


    }

}
